import sys
from PyQt6 import uic
from PyQt6.QtWidgets import QApplication, QLabel, QSizePolicy
from PyQt6.QtWidgets import QWidget,QVBoxLayout

class MiddleWidget(QWidget):
    def __init__(self,parent = None):
        super().__init__(parent)
        self.init_ui()
    def init_ui(self):
        layout = QVBoxLayout(self)
        layout.setContentsMargins(0,0,0,0)
        try:

            uic.loadUi("定频输出.ui", self)

            self.apply_styles()
            self.set_background()
            self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
        except FileNotFoundError:
            print("ui文件未找到，使用备用布局")
            self.label = QLabel("定频输出", self)
            self.label.setStyleSheet("font-size:24px;text-align:center;")
            layout.addWidget(self.label)
            return



    def set_background(self):
        self.setStyleSheet("background-color:white;")
    # 标签：边框颜色
    def apply_styles(self):
        label = self.findChild(QLabel,"label")
        if label:
            label.setStyleSheet("border:1px solid #e0e0e0")


if __name__ == '__main__':
    app = QApplication(sys.argv)
    middle = MiddleWidget()
    middle.show()
    sys.exit(app.exec())